
// components/fold-cell/fold-cell.ts
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    limitHeight: {
      type: Number,
      value: 100
    },

  },

  /**
   * 组件的初始数据
   */
  data: {
    isExpand: false,
    isShowAction: false,
    maxheight: ''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    checkComponentHeight() {
      const query = wx.createSelectorQuery().in(this);
      query.select('#targetComponent')
        .boundingClientRect(rect => {
          if (rect) {
            // console.log(rect)
            this.setData({
              isShowAction: rect.height > this.data.limitHeight,
              maxheight: `max-height: ${this.properties.limitHeight}rpx;`
            });
          }
        })
        .exec();
    },
    onClickExpand() {
      const flag = !this.data.isExpand
      this.setData({
        isExpand: flag
      })
    }
  },

  lifetimes: {
    attached() {

    },
    ready() {
      setTimeout(() => {
        this.checkComponentHeight()
      }, 50);
    },

  }
})